/*
 * @Author: 米爱 1969407518@qq.com
 * @Date: 2025-06-10 11:42:15
 * @LastEditors: 米爱 1969407518@qq.com
 * @LastEditTime: 2025-08-14 14:41:37
 * @FilePath: \CraneOperator-xm\src\store\index.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import Vue from "vue";
import Vuex from "vuex";
import createPersistedState from "vuex-persistedstate";
Vue.use(Vuex);

const store = new Vuex.Store({
  state: {
    textStudentInfo: "",
    examineeId: "",
    score: "",
    // 添加新的设备配置状态
    // ----上饶---
    // szIP: "192.168.110.32", //上饶设备ip
    // szPassword: "yxkj2025", //上饶摄像头登录密码
    // szDeviceIdentify: "192.168.110.32_80", // 上饶

    // ----厦门---
    szIP: "192.168.1.64", //设备ip
    szPassword: "yxkj2024", //厦门摄像头登录密码
    szDeviceIdentify: "192.168.1.64_80",

    // ----本地特检院---
    szIP: "192.168.110.158", //设备ip
    szPassword: "yx123456", //特检院摄像头登录密码
    szDeviceIdentify: "192.168.110.158_80",
    // szIP: "192.168.1.64", //设备ip
    // szPassword: "yx123456", //特检院摄像头登录密码
    // szDeviceIdentify: "192.168.1.64_80",
  },

  mutations: {
    saveStudentinfo(state, data) {
      state.textStudentInfo = data;
      state.examineeId = data.id;
    },
    score(state, score) {
      state.score = score;
    },
    // 添加更新设备配置的mutation
    setDeviceConfig(state, config) {
      state.szIP = config.szIP;
      state.szPassword = config.szPassword;
      state.szDeviceIdentify = config.szDeviceIdentify;
    },
  },
  actions: {},
  getters: {},
  modules: {},
  plugins: [
    createPersistedState({
      // 存储方式：localStorage、sessionStorage、cookies  默认: localStorage
      storage: window.localStorage,
      // 存储的 key 的key值
      key: "store",
      render(state) {
        // 要存储的数据：本项目采用es6扩展运算符的方式存储了state中所有的数据
        return { ...state };
      },
    }),
  ],
});

export default store;
